addUnp    PROC NEAR32
; add two 8 byte unpacked BCD numbers
; parameter 1:  operand1 and destination address
; parameter 2:  operand2 address
; author:  R. Detmer   revised:  5/98
          push ebp            ; establish stack frame
          mov  ebp, esp
          push esi            ; save registers
          push edi
          push eax
          push ecx
          mov  edi, [ebp+12]  ; destination address
          mov  esi, [ebp+8]   ; source address
          add  esi, 8         ; point at byte after source
          add  edi, 8         ; byte after destination
          clc                 ; clear carry flag
          mov  ecx, 8         ; count of bytes to process
forAdd:   dec  edi            ; point at operand bytes to left
          dec  esi
          mov  al, [edi]      ; get one operand byte
          adc  al, [esi]      ; add other operand byte
          aaa                 ; adjust to unpacked BCD
          mov  [edi], al      ; save sum
          loop forAdd         ; repeat for all 8 bytes
          pop  ecx            ; restore registers
          pop  eax
          pop  edi
          pop  esi
          pop  ebp
          ret  8         ; return, discarding paramters
addUnp    ENDP

